package com.tr.rentcar.controller.houtai.admin;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONArray;
import com.tr.rentcar.model.bean.Admin_he;
import com.tr.rentcar.model.dao.AdminDao;
@WebServlet("/admingetjson")
public class AdmingetjsonControllor extends HttpServlet {
	Admin_he admin_he=new Admin_he();
	AdminDao AdminDao=new AdminDao();
	private static final long serialVersionUID = 1L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {req.setCharacterEncoding("utf-8");
		resp.setContentType("application/json;charset=utf-8");
			List<Admin_he> admin_he=AdminDao.findall();
		req.setAttribute("admin_he", admin_he);
		PrintWriter out=resp.getWriter();
		out.print(JSONArray.toJSONString(admin_he));
		} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		doGet(req, resp);
	}
}
